package reflect;

import java.lang.reflect.Method;

/**
 * 调用有参方法
 */
public class ReflectDemo5 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();
        //say(String,String)
        Method m = cls.getMethod("say",String.class,String.class);
        m.invoke(obj,"凡凡","人称我是小牙签~");

        Method m2 = cls.getMethod("say",String.class,int.class);
        m2.invoke(obj,"乖乖",5);




    }
}
